package jgl.vajra.kingkong.part.mine.activity;

import android.text.TextUtils;

import java.util.HashMap;
import java.util.Map;

import jgl.vajra.kingkong.R;
import jgl.vajra.kingkong.bean.BillDetailsBean;
import jgl.vajra.kingkong.databinding.ActivityBillDetailsBinding;
import jgl.vajra.kingkong.manager.AccountManager;
import jgl.vajra.kingkong.part.mine.contract.BillDetailsContract;
import jgl.vajra.kingkong.part.mine.viewModel.BillDetailsViewModel;
import jgl.vajra.kingkong.widget.mvvm.factory.CreateViewModel;
import jgl.vajra.kingkong.widget.mvvm.view.BaseMVVMActivity;
import jgl.vajra.kingkong.widget.utils.UIUtils;

@CreateViewModel(BillDetailsViewModel.class)
public class BillDetailsActivity extends BaseMVVMActivity<BillDetailsViewModel, ActivityBillDetailsBinding> implements BillDetailsContract.View {

    private String withdrawId;

    @Override
    public int getLayoutId() {
        return R.layout.activity_bill_details;
    }

    @Override
    public void initView() {
        super.initView();

        withdrawId = getIntent().getStringExtra("withdrawId");

        requestNetData();
    }

    private void requestNetData() {
        Map<String, Object> map = new HashMap<>();
        map.put("Authorization", AccountManager.getInstance().getLoginData(UIUtils.getContext()).authorization);
        map.put("withdrawId",withdrawId);
        mViewModel.getBillDetailsData(map);

    }

    @Override
    public void returnBillDetailsData(BillDetailsBean data) {
        if (!TextUtils.isEmpty(data.withdrawStatusOneDate)) {
            data.refundStatus = 1;
        }
        if (!TextUtils.isEmpty(data.withdrawStatusTwoDate)) {
            data.refundStatus = 2;
        }
        if (!TextUtils.isEmpty(data.withdrawStatusThreeDate)) {
            data.refundStatus = 3;
        }
        mBinding.setData(data);
    }
}
